<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/public/header.jsp"%>
<% 
	String gd_id = request.getParameter("gd_id");
%>

<html>
	<head>
		<title>工单内容管理</title>
	</head>
	<script type="text/javascript">
		$(function(){
			$("#table").datagrid({
				title:"工单内容管理",
				iconCls:'icon-edit',
				loadMsg:'正在加载数据，请稍后......',
				url:'<%=contextPath %>/springMVC/gd/listPageGDContent?gd_id=<%=gd_id%>',
				rownumbers:true,
				fitColumns:true,
				nowrap:false,
				idField:'id',
				frozenColumns:[[
	                {field:'ck',checkbox:true},
				    {title:'内容id',field:'id',hidden:true},
				    {title:'工单id',field:'gd_id',hidden:true}
				]],
				columns:[[
					{title:'工单编号',field:'gd_code',width:100,align:'center'},
					{title:'工单名称',field:'gd_name',width:100,align:'center'},
					{title:'内容编号',field:'gd_content_code',width:50,align:'center'},
					{title:'当前状态',field:'status',hidden:true},
					{title:'当前状态',field:'status_desc',width:100,align:'center'},
					{title:'操作',field:'edit',width:50,align:'center',formatter:function(value,rowData,rowIndex){
						if(rowData.gd_content_code == '1'){
	                    	return "<input type='button' style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-modify' title='编辑' onclick=\"javascript:addOrEditGd('"+rowData.gd_id+"','"+rowData.id+"');\"/>";
						}
	                    return "<input type='button' style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-modify' title='编辑' onclick=\"javascript:addOrEditGd('"+rowData.gd_id+"','"+rowData.id+"');\"/> &nbsp;&nbsp;<input type='button' style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-no' title='删除' onclick=\"javascript:addOrEditGd('"+rowData.gd_id+"','"+rowData.id+"');\"/>";
	
					}},
					{title:'审批',field:'shenpi',width:50,align:'center',formatter:function(value,rowData,rowIndex){
	                    return "<input type='button' style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-shenpi' title='工单审批' onclick=\"javascript:shenpi('"+rowData.id+"');\"/>";
	
					}},

					{title:'现场交底',field:'more',width:50,align:'center',formatter:function(value,rowData,rowIndex){
	                    return "<input type='button' style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;' class='icon-details' title='工单详情' onclick=\"javascript:setRelativeData();\"/>";
	
					}}
				]],
				toolbar:
				[
					{
						id:'delete',
						text:'删除',
						iconCls:"icon-remove",
						handler:function(){
							var rows=$('#table').datagrid('getSelections');
							var deleteVar="";
							if(rows.length==0)
							{
								$.messager.alert('提示','选中要删除的记录');  
								return ;
							}
							for(var i=0;i<rows.length;i++)
							{
								if(i==(rows.length-1))
								{
									deleteVar+=rows[i].id;
								}else
								{
									deleteVar+=rows[i].id+",";
								}
							}
							$.messager.confirm('确认','您确认删除该记录信息？',function(msg){
								if(msg){
									$.ajax({
										type:'POST',
										url:"<%=contextPath %>/springMVC/gd/deleteGd",
										data:"ids="+deleteVar,
										dataType:"json",
										success:function(rtJson){
											if(rtJson.rtState == '0'){
												table_reload(rows.length);
											}
											else{
												warningInfo(rtJson.rtMsrg);
											}
										}
									});
								}
							});
						}
					},'-',
				   {
						id:'add',
						text:'新增',
						iconCls:"icon-add",
						handler:function(){
							addOrEditGd(0);
						}
					}
				],
				pageSize:10,
				pageList : [10,50,100],  
				pagination:true,
				onLoadSuccess:function(rtJson){
					if(rtJson.rtState== '1')
					{
						$.messager.alert('提示',rtJson.rtMsrg);
					}
				}
			});
		});
		
		function addOrEditGd(type,id){
			if(type==0){
				openDialogResize("<%=contextPath %>/springViews/gd/addOrEditGd.jsp?callback=rtCallBack",1000, 800);
			}else{
				openDialogResize('<%=contextPath %>/springViews/gd/addOrEditGd.jsp?callback=rtCallBack&id='+id,1000, 800);
			}
		}
		function rtCallBack(){
			$('#table').datagrid('reload');
		}
		function gd_content(id){
			openDialogResize("<%=contextPath %>/springViews/gd/gdContentManage.jsp?gd_id="+id,1000, 800);
		}
		
	</script>
	<body style="height: 97%">
		<div id="table" data-options="fit:true" ></div>
	</body>
</html>
